package routers

import (
	"myRbac/controllers/roleController"
	"myRbac/controllers/roleMenuController"
	middleware "myRbac/middlewares"

	"github.com/gin-gonic/gin"
)

func RoleApi(r *gin.RouterGroup) {
	var role roleController.RoleController
	var menuRole roleMenuController.RoleMenuController
	roleRouter := r.Group("/role", middleware.JWTAuthPlus())
	{
		roleRouter.GET("/", role.QueryRoles)
		roleRouter.GET("/all", role.QueryAllRoles)
		roleRouter.GET("/:id", role.QueryRoleById)
		roleRouter.POST("/", role.AddRole)
		roleRouter.PUT("/", role.UpdateRole)
		roleRouter.DELETE("/", role.DeleteRole)
	}
	roleMenuRouter := r.Group("/rolemenu", middleware.JWTAuthPlus())
	{
		roleMenuRouter.POST("/", menuRole.AddRoleWithMenu)
		roleMenuRouter.PUT("/", menuRole.UpdateRoleWithMenu)
		roleMenuRouter.GET("/:id", menuRole.QueryRoleMenuTreesById)
	}
}
